<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Form extends MY_Controller {

    public function __construct(){
        parent::__construct();
        $this->header_data['open'] = true;
		$this->load->library('pagination');
    }

	public function common($start=0)
	{ 	
        $this->header_data['title'] = '时间'; //Title
        $this->header_data['active'] = 'common';
		$this->load->model('Comments');
		$comments=$this->Comments->get_comments();
		//拉取六个月内报表数据  25920000秒=30天
		$month_data_good=$this->Comments->get_month_data('good');
		$month_data_bad=$this->Comments->get_month_data('bad');
		$month_data_neutral=$this->Comments->get_month_data('neutral');
		
		//
		//分页
		//每页显示条数
		$per_page=10;
		//
		

		$config['base_url'] = '/index.php/form/common';
		$config['total_rows'] = count($comments);
		$config['per_page'] = $per_page;
		$config['enable_query_strings'] = true;
		$config['next_link'] ='<i class="icon-chevron-right"></i>';
		$config['prev_link'] ='<i class="icon-chevron-left"></i>';
		$config['first_link'] ='<i class="icon-step-backward"></i>';
		$config['last_link'] ='<i class="icon-step-forward"></i>';



		$this->pagination->initialize($config);
		$total=count($comments)/$per_page;
		$per=($start+$per_page)/$per_page;
		
		$msg="第".$per."/".ceil($total)."页";
		$page= $this->pagination->create_links();
		//
		$comments=array_slice($comments,$start,$per_page);
		$result = array(
			'month_data_good'     =>  $month_data_good,
			'month_data_bad'      =>  $month_data_bad,
			'month_data_neutral'  =>  $month_data_neutral,
			'comments'            =>  $comments,
			'page'                =>  $page,
			'msg'                 =>  $msg,
		);
		$this->display('common',$result);
	}

	public function validation(){
		$this->display('validation');
	}

	public function price(){
		$this->display('price');
	}

	public function goods(){
		$this->display('goods');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */